﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.ComponentModel.DataAnnotations;
using System.ApplicationModel;

namespace Anagramme.Contracts
{
    /// <summary>
    /// Définition des informations d'un lobby
    /// </summary>
    [DataContract]
    public class LobbyInfo : ObservableObject
    {
        #region Fields
        private GameModes _gameMode;
        private int _maxWordsLength;
        private int _minWordsLength;
        private int _targetRounds;
        private int _targetScore;
        #endregion

        #region Properties
        /// <summary>
        /// Obtient ou définit le mode de jeu
        /// </summary>
        [DataMember]
        [Display(Name = "GameMode_Name", ResourceType = typeof(Resources.LobbyInfoStrings))]
        public GameModes GameMode
        {
            get { return this._gameMode; }
            set
            {
                if (!this._gameMode.Equals(value))
                {
                    base.RaisePropertyChanging();
                    this._gameMode = value;
                    base.RaisePropertyChanged();
                }
            }
        }

        /// <summary>
        /// Obtient ou définit la longueur maximale des mots
        /// </summary>
        [DataMember]
        [Display(Name = "MaxWordsLength_Name", ResourceType = typeof(Resources.LobbyInfoStrings))]
        [Range(5, 8, ErrorMessageResourceName = "MaxWordsLength_RangeException", ErrorMessageResourceType = typeof(Resources.LobbyInfoStrings))]
        [CustomValidation(typeof(WordsValidator), "ValidateMaxWordsLength", ErrorMessageResourceName = "MaxWordsLength_CustomException", ErrorMessageResourceType = typeof(Resources.LobbyInfoStrings))]
        public int MaxWordsLength
        {
            get { return this._maxWordsLength; }
            set
            {
                if (!this._maxWordsLength.Equals(value))
                {
                    base.RaisePropertyChanging();
                    this._maxWordsLength = value;
                    base.RaisePropertyChanged();
                }
            }
        }

        /// <summary>
        /// Obtient ou définit la longueur minimale des mots
        /// </summary>
        [DataMember]
        [Display(Name = "MinWordsLength_Name", ResourceType = typeof(Resources.LobbyInfoStrings))]
        [Range(5, 8, ErrorMessageResourceName = "MinWordsLength_RangeException", ErrorMessageResourceType = typeof(Resources.LobbyInfoStrings))]
        [CustomValidation(typeof(WordsValidator), "ValidateMinWordsLength", ErrorMessageResourceName = "MinWordsLength_CustomException", ErrorMessageResourceType = typeof(Resources.LobbyInfoStrings))]
        public int MinWordsLength
        {
            get { return this._minWordsLength; }
            set
            {
                if (!this._minWordsLength.Equals(value))
                {
                    base.RaisePropertyChanging();
                    this._minWordsLength = value;
                    base.RaisePropertyChanged();
                }
            }
        }

        /// <summary>
        /// Obtient ou définit le nombre de rounds cible
        /// </summary>
        [DataMember]
        [Display(Name = "TargetRounds_Name", ResourceType = typeof(Resources.LobbyInfoStrings))]
        [Range(1, 100, ErrorMessageResourceName = "TargetRounds_RangeException", ErrorMessageResourceType = typeof(Resources.LobbyInfoStrings))]
        public int TargetRounds
        {
            get { return this._targetRounds; }
            set
            {
                if (!this._targetRounds.Equals(value))
                {
                    base.RaisePropertyChanging();
                    this._targetRounds = value;
                    base.RaisePropertyChanged();
                }
            }
        }

        /// <summary>
        /// Obtient ou définit le score cible
        /// </summary>
        [DataMember]
        [Display(Name = "TargetScore_Name", ResourceType = typeof(Resources.LobbyInfoStrings))]
        [Range(10, 100, ErrorMessageResourceName = "TargetScore_RangeException", ErrorMessageResourceType = typeof(Resources.LobbyInfoStrings))]
        public int TargetScore
        {
            get { return this._targetScore; }
            set
            {
                if (!this._targetScore.Equals(value))
                {
                    base.RaisePropertyChanging();
                    this._targetScore = value;
                    base.RaisePropertyChanged();
                }
            }
        }
        #endregion
    }
}
